package com.compty.paint.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.compty.core.hibernate.HibernateEntityDao;
import com.compty.paint.domain.AuditState;

/**
 * @Todo:审核状态 Manager (未送审、审核中、通过、驳回 )
 * @author: 朱庆辉
 * @CreateTime:2012-4-12 上午10:53:30
 */
public class AuditStateManager  extends HibernateEntityDao<AuditState>{
	
	private static Map<String,AuditState> auditStateMap = new HashMap<String, AuditState>();
	
	private static List<AuditState> auditStateList = null;
	
	public AuditState findUniqueBy(String fieldName, Object value){
		
		if("english_name".equals(fieldName)){
			
			if( auditStateMap.size() == 0){
				List<AuditState>  list = getAll();
				for (AuditState auditState : list) {
					String key = auditState.getEnglish_name();
					auditStateMap.put(key, auditState);
				}
			}
			
			return auditStateMap.get(value);
		}
		else{
			return super.findUniqueBy(fieldName, value);
		}
	}
	
	public List<AuditState> getAll(){
		if(auditStateList == null){
			return super.getAll();
		}else{
			return auditStateList;
		}
	}

}
